<?php
/**
 * @author tungck
 * @filesource hoso_model.php
 * file model for process staff manager
*/
?>

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class hoso_model extends CI_Model{
    
    public $tableName = 'hosonhanvien';
    
    function hoso_model(){
        parent::__construct();
        $this->load->helper('url');
        $this->load->database();
        
    }
    
    
    //l?y thông tin v? nhân viên có id h? so là $id
    public function getDetailStaff($id){
        
        $query = $this->db->get_where('hosonhanvien','MaHoSo = '.$id);
        if($query){
            return $query->result();
        }else{
            return false;
        }
        
    }
    
    
    function updateStaff($data){
        $this->db->where('MaHoSo', $data['MaHoSo']);
        $this->db->update('hosonhanvien', $data); 
    }
    
    public function updateImg($id,$img){
        $query = $this->db->query("UPDATE hosonhanvien SET  AnhDaiDien =  '".$img."' WHERE  MaHoSo =".$id);
        if($query){
            return true;
        }else{
            return false;
        }
    }
    
    public function getById($id){
        $query = $this->db->get_where('hosonhanvien', 'MaHoSo = '.$id);
        if($query){
            return $query->result();
        }else{
            return false;
        }
    }
    
    function getList($data){
        $recordCount = $this->db->count_all_results('hosonhanvien');
        $query = $this->db->query("SELECT * FROM hosonhanvien ORDER BY " . $data['sort'] . " LIMIT " . $data['startIndex'] . "," . $data['pageSize'] . ";");
        if($query){
            $result['query'] = $query->result();
            $result['recordCount'] = $recordCount;
            return $result;
        }else{
            return false;
        }
        
    }
    
    
}

?>